home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 2: CDPD 1 / Almathera Ten on Ten - Disc 2: CDPD 1.iso / pd / 351-375 / 351 / pdc / pdcsrc.lzh / PDC / EntryExit.s < prev    next >
Text File  |  1990-04-06  |  2KB  |  96 lines

  1.     SECTION    2,DATA
  2. nest_level
  3.     DC.l    -1
  4.  
  5.     SECTION    1,CODE
  6. ;
  7. ; .entry
  8. ;
  9. ; Upon entry, D0 contains the number of bytes of stack space required to make
  10. ; the function call (return addr+local frame).  A0 is a pointer to the name of
  11. ; the function.  Scrathpad registers (D0-D1/A0-A1) may be modified, all others
  12. ; must be preserved upon return.
  13. ;
  14. .entry:
  15.     move.l    D3,-(A7)
  16.  
  17. ;    Save name (A0) on the stack so we can use it later
  18.  
  19.     move.l    A0,-(A7)
  20.  
  21. ;    Output nest_level number of spaces (ascii 32)
  22.  
  23.     move.l    nest_level,D3
  24.     bmi    inc_static
  25.  
  26.     move.l    _output,-(A7)
  27.     pea    32
  28. loop1
  29.     jsr    _fputc
  30.     dbra    D3,loop1
  31.     add.w    #8,A7
  32.  
  33. inc_static
  34.     addq.l    #1,nest_level
  35.  
  36. ;;;        fprintf( stderr, "%s [\n", name (which is still on the stack !-);
  37.  
  38.     pea    enter_fmt
  39.     move.l    _output,-(A7)
  40.     jsr    _fprintf
  41.     add.w    #12,A7        ; we're also clearing off the name
  42.  
  43.     move.l    (A7)+,D3
  44.     rts
  45.  
  46. ;
  47. ; .exit
  48. ;
  49. ; Upon entry, D0 contains the return value of the routine and A0 is a pointer 
  50. ; the name of the function.  Upon return, D0 and the non-scratchpad registers 
  51. ; are preserved.
  52. ;
  53. .exit:
  54.     movem.l    D0/D3,-(A7)
  55.  
  56. ;    Decrement nesting count
  57.  
  58.     subq.l    #1,nest_level
  59.  
  60. ;    Output nest_level number of spaces (ascii 32)
  61.  
  62.     move.l    nest_level,D3
  63.     bmi    close_bracket
  64.  
  65.     move.l    _output,-(A7)
  66.     pea    32
  67. loop2
  68.     jsr    _fputc
  69.     dbra    D3,loop2
  70.     addq.w    #8,A7
  71.  
  72. close_bracket
  73.  
  74. ;;;        fprintf( stderr,  "] (0x08x)\n", D0 (which saved on the stack !-);
  75.     
  76.     pea    exit_str
  77.     move.l    _output,-(A7)
  78.     jsr    _fprintf
  79.  
  80.     addq.w    #8,A7
  81.     movem.l    (A7)+,D0/D3      ; Very important to restore return value!
  82.     rts
  83.  
  84. exit_str
  85.     DC.b    93,32,40,48,120,37,48,56,120,41,10,0
  86. enter_fmt
  87.     DC.b    37,115,32,91,10,0,0
  88.  
  89.     XDEF    .entry
  90.     XDEF    .exit
  91.     XREF    _output
  92.     XREF    _fputc
  93.     XREF    _fprintf
  94.     END
  95.  
  96.